package com.shbaiche.bifenba.adapter.home;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shbaiche.bifenba.R;

import java.util.List;

public class SearchQuiteAdapter extends BaseAdapter {
    private Context context;

    private List<String> his;


    public SearchQuiteAdapter(Context context, List<String> his) {
        super();
        this.context = context;
        this.his = his;
    }

    public void setData(List<String> his) {
        this.his = his;
        notifyDataSetChanged();
    }


    @Override
    public int getCount() {
        if (his == null)
            return 0;
        return his.size();
    }

    @Override
    public String getItem(int arg0) {
        return his.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(final int position, View v, ViewGroup arg2) {
        ViewHolder holder = null;
        if (v == null) {
            holder = new ViewHolder();
            v = LayoutInflater.from(context).inflate(R.layout.adapter_search_quite, null);
            holder.tv = (TextView) v.findViewById(R.id.quite_tv);
            v.setTag(holder);
        } else {
            holder = (ViewHolder) v.getTag();
        }
        holder.tv.setText(his.get(position));

        return v;
    }

    class ViewHolder {
        TextView tv;
    }
}
